package com.assignwork.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class WorkArrangeShipVO {

    @JsonSerialize(using = ToStringSerializer.class)
    private Long assemblyLineId;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long planId;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long arrangeId;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long fixedMachineId;
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    private LocalDateTime startTime;
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    private LocalDateTime endTime;
    private String cargoType;
    private String cargoTypeName;
    private String packageBulk;
    private String packageBulkName;
    private String lineNo;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long lineId;
    private String timeSpace;
    private String loadType;
    private String loadTypeName;
    private String fixedMachineName;
    private String fixedMachinePosition;
    private String fixedMachinePositionName;
    private String fixedMachineNo;
    private BigDecimal planTon;
    private String realCabin1;
    private String realCabin1Name;
    private String realCabin2;
    private String realCabin2Name;
    private String realHatch1;
    private String realHatch1Name;
    private String realHatch2;
    private String realHatch2Name;
    private String realCabinAndHatch1;
    private String realCabinAndHatch1Name;
    private String realCabinAndHatch2;
    private String realCabinAndHatch2Name;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long cabinInfoId;
    private String underMachineKind;
    private String underMachineName;
    private Long underMachineCorp;
    private String underMachineCorpName;
    private String underMachineCount;

    private String flowMachineKind;
    private String flowMachineName;
    private Long flowMachineTeam;
    private String flowMachineTeamName;
    private String flowMachineCount;
    
    private String workerTeam;
    private String workerTeamName;
    private String workerCount;

    private List<WorkArrangeShipVO> cabins;
    private List<WorkArrangeShipVO> underMachines;
    private List<WorkArrangeShipVO> flowMachines;
    private List<WorkArrangeShipVO> workers;
    private List<AssignWorkInfoVO> workInfo;
    private List<AssignWorkVO> assignWorks;
    
    @JsonSerialize(using = ToStringSerializer.class)
    private Long assignWorkId;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long arrangeInfoId;

    public String getRealCabinAndHatch1Name() {
        if (Func.isNoneBlank(realCabin1) && Func.isNoneBlank(realHatch1)) {
            return realCabin1Name + realHatch1Name;
        }
        return realCabinAndHatch1Name;
    }

    public String getRealCabinAndHatch2Name() {
        if (Func.isNoneBlank(realCabin2) && Func.isNoneBlank(realHatch2)) {
            return realCabin2Name + realHatch2Name;
        }
        return realCabinAndHatch2Name;
    }

    public String getFixedMachineName() {
        if (Func.isNoneBlank(fixedMachinePosition)) {
            return fixedMachinePositionName + "门吊_" +fixedMachineName;
        }

        return fixedMachineName;
    }
}
